#include <iostream>
using namespace std;
/*
    像素模糊核心思想：
    1. 分为两个数组来计算存储便于分类讨论
    2. 第一种，周围像素的变换
    3. 第二种，中间像素的变化
*/
int main()
{
    int new_[100][100] = {0}, old_[100][100] = {0};
    int n, m, temp;
    cin >> n >> m;
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < m; j++)
        {
            cin >> temp;
            new_[i][j] = temp;
            old_[i][j] = temp;
        }
    }

    // 中心像素的变化
    for (size_t i = 1; i < n - 1; i++) // 逐行扫描
    {
        for (size_t j = 1; j < m - 1; j++) // 逐列扫描
        {
            new_[i][j] = (old_[i - 1][j] + old_[i + 1][j] + old_[i][j - 1] + old_[i][j + 1] + old_[i][j]) / 5;
        }
    }

    for (size_t i = 0; i < n; i++) // 逐行扫描
    {
        for (size_t j = 0; j < m; j++) // 逐列扫描
        {
            cout << new_[i][j] << " ";
        }
        cout << endl;
    }
}